import datetime
from mongoengine import *


# Create your models here.

class Menu(EmbeddedDocument):
    # 菜单
    name = StringField(max_length=1024)
    amount = IntField(max_length=1024)
    pic_url = StringField(max_length=1024)
    price = FloatField(max_length=1024)
    menu_id = IntField(max_length=1024)
    remark = StringField(max_length=1024)

class Orders(Document):
    # 订单
    community = StringField(max_length=1024)
    point = StringField(max_length=1024)
    discount = FloatField(max_length=1024)
    room_num = StringField(max_length=1024)
    delivery_name = StringField(max_length=1024)
    delivery_tel = StringField(max_length=1024)
    pay_time = DateTimeField(default=datetime.datetime.now)
    order_num = StringField(max_length=1024)
    user_id = StringField(max_length=1024)
    status = StringField(max_length=1024)
    payment = FloatField(max_length=1024)
    point_address = StringField(max_length=1024)
    open_id = StringField(max_length=1024)
    result_code = StringField(max_length=1024)
    total_fee = IntField(required=True)
    transaction_id = StringField(max_length=1024)
    time_end = StringField(max_length=1024)
    cookbook_id = StringField(max_length=1024)
    remarks = StringField(max_length=1024)
    menus = ListField(EmbeddedDocumentField(Menu))
    meta = {'collection': 'order'}